package operation.util;

import java.math.BigDecimal;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;

public final class ParamUtil {
    public static String getString(Map<String, Object> params, String key) {
        Object strObj = params.get(key);
        return strObj != null ? String.valueOf(strObj) : null;
    }

    public static String getString(Map<String, Object> params, String key, String defaultVal) {
        Object strObj = params.get(key);
        return strObj != null ? String.valueOf(strObj) : defaultVal;
    }

    public static int getInt(Map<String, Object> params, String key) {
        String val = getString(params, key);
        int ret = 0;
        if (StringUtils.isNotBlank(val)) {
            try {
                ret = Integer.parseInt(val);
            } catch (Exception var5) {
            }
        }

        return ret;
    }

    public static int getInt(Map<String, Object> params, String key, int defaultVal) {
        String val = getString(params, key);
        int ret = defaultVal;
        if (StringUtils.isNotBlank(val)) {
            try {
                ret = Integer.parseInt(val);
            } catch (Exception var6) {
            }
        }

        return ret;
    }

    public static Integer getInteger(Map<String, Object> params, String key, Integer defaultVal) {
        String val = getString(params, key);
        Integer ret = defaultVal;
        if (StringUtils.isNotBlank(val)) {
            try {
                ret = Integer.parseInt(val);
            } catch (Exception var6) {
            }
        }

        return ret;
    }

    public static long getLong(Map<String, Object> params, String key) {
        String val = getString(params, key);
        long ret = 0L;
        if (StringUtils.isNotBlank(val)) {
            try {
                ret = Long.parseLong(val);
            } catch (Exception var6) {
            }
        }

        return ret;
    }

    public static long getLong(Map<String, Object> params, String key, long defaultVal) {
        String val = getString(params, key);
        long ret = defaultVal;
        if (StringUtils.isNotBlank(val)) {
            try {
                ret = Long.parseLong(val);
            } catch (Exception var8) {
            }
        }

        return ret;
    }

    public static BigDecimal getDecimal(Map<String, Object> params, String key) {
        String val = getString(params, key);
        BigDecimal ret = BigDecimal.ZERO;
        if (StringUtils.isNotBlank(val)) {
            try {
                ret = new BigDecimal(val);
            } catch (Exception var5) {
            }
        }

        return ret;
    }

    public static BigDecimal getDecimal(Map<String, Object> params, String key, BigDecimal defaultVal) {
        String val = getString(params, key);
        BigDecimal ret = defaultVal;
        if (StringUtils.isNotBlank(val)) {
            try {
                ret = new BigDecimal(val);
            } catch (Exception var6) {
            }
        }

        return ret;
    }

    private ParamUtil() {
    }
}
